package com.github.zyf.ioaj.export;

/**
 * <h1>内容加载器</h1>
 * <p>用于加载导出所需要的内容</p>
 * <p>
 * 构造函数需要包括如下必须参数
 * <ul>
 *     <li>导出标题：{@link #title}</li>
 *     <li>导出作者：{@link #author}</li>
 *     <li>导出备注：{@link #message}</li>
 * </ul>
 * <p>
 * 在导出完成后，一定要调用{@link #complete(Class)}方法，
 * 否则内容会不完整，将抛出{@link com.github.zyf.ioaj.exception.ContentBuilderException}异常，
 * 异常类型为{@link com.github.zyf.ioaj.exception.constant.ContentBuilderExceptionType#INCOMPLETE_CONTENT}
 * </p>
 *
 * @author zyf
 */
public abstract class ContentBuilder {

    /**
     * 标题
     */
    private String title;
    /**
     * 作者
     */
    private String author;
    /**
     * 备注
     */
    private String message;

    /**
     * 是否加载完成
     */
    private boolean isCompleted;

    public ContentBuilder(String title, String author, String message) {
        this.title = title;
        this.author = author;
        this.message = message;
        this.isCompleted = false;
    }

    /**
     * 标志内容加载结束，需要传入加载的目标类用作结束符
     *
     * @param clazz 加载的目标类
     */
    public abstract void complete(Class<?> clazz);

    public abstract void appendString(String key, String desc, String value);
    public abstract void appendStrings_1(String key, String desc, String[] value);
    public abstract void appendStrings_2(String key, String desc, String[][] value);

    public abstract void appendBoolean(String key, String desc, boolean value);

    public abstract void appendInt(String key, String desc, int value);
    public abstract void appendInts_1(String key, String desc, int[] value);
    public abstract void appendInts_2(String key, String desc, int[][] value);

    public abstract void appendDouble(String key, String desc, double value);

    public abstract void appendDoubles_1(String key, String desc, double[] value);

    public abstract void appendDoubles_2(String key, String desc, double[][] value);

    public abstract void appendObjectHeader(String key, String desc);

    public abstract void appendObjectEnd(Object o);

    public abstract void appendNewNodeHeader(String nodename, String desc);

    public abstract void appendNewNodeEnd(String nodename);

    public abstract void appendNewArrayHeader(String key);

    public abstract void appendNewArrayEnd(String key);

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public boolean isCompleted() {
        return isCompleted;
    }

    protected void setCompleted() {
        isCompleted = true;
    }
}
